package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsRegionMapper;
import com.qf.pojo.DtsRegion;
import com.qf.service.DtsRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @version 1.0
 * @auther Administrator
 * @date 2023/2/24 16:56
 */
@Service
public class DtsRegionServiceImpl implements DtsRegionService {

    @Autowired
    private DtsRegionMapper dtsRegionMapper;

    @Override
    public IPage<DtsRegion> findListByQuery(Integer page, Integer limit, String sort, String order, String name, Integer code) {

        return dtsRegionMapper.selectPage(new Page<DtsRegion>(page,limit),new QueryWrapper<DtsRegion>()
                .like(!StringUtils.isEmpty(name),"name",name)
                .eq(!StringUtils.isEmpty(code),"code",code)
                .orderBy(!StringUtils.isEmpty(sort),"ASC".equalsIgnoreCase(order),sort));
    }
}
